const currey = function (fn) {
  let arrs = [];
  function curried(...arg) {
    arrs = [...arrs, ...arg];
    if (fn.length <= arrs.length) {
      return fn(...arrs);
    } else {
      return curried;
    }
  }
  return curried;
};

function add(a, b, c) {
  return a + b + c;
}

const curryFun = currey(add);
const f1 = curryFun(1);
const f2 = f1(2);
const f3 = f2(3);
console.log(f1, f2, f3);
